# Contributor: Jonathan Schleifer <js@nil.im>
# Maintainer: Jonathan Schleifer <js@nil.im>
pkgname=objfw
pkgver=1.0.5
pkgrel=1
pkgdesc="Portable, lightweight framework for the Objective-C language"
url="https://objfw.nil.im/"
arch="all"
license="QPL-1.0 OR GPL-3.0-only OR GPL-2.0-only"
makedepends="clang17 openssl-dev doxygen"
subpackages="$pkgname-dev $pkgname-doc libobjfw1:_libobjfw
	libobjfwrt1:_libobjfwrt libobjfwtls1:_libobjfwtls ofarc:_ofarc
	ofdns:_ofdns ofhash:_ofhash ofhttp:_ofhttp"
source="https://objfw.nil.im/downloads/objfw-$pkgver.tar.gz"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-rpath \
		OBJC="clang -target $CHOST"
	make
}

check() {
	make check
}

package() {
	depends="libobjfw1=$pkgver-r$pkgrel libobjfwrt1=$pkgver-r$pkgrel
		libobjfwtls1=$pkgver-r$pkgrel objfw-dev=$pkgver-r$pkgrel
		objfw-doc=$pkgver-r$pkgrel ofarc=$pkgver-r$pkgrel
		ofdns=$pkgver-r$pkgrel ofhash=$pkgver-r$pkgrel
		ofhttp=$pkgver-r$pkgrel"

	make DESTDIR="$pkgdir" install
}

dev() {
	amove usr/bin/objfw-compile
	amove usr/bin/objfw-config
	amove usr/bin/objfw-embed
	amove usr/bin/objfw-new
	amove usr/include
	amove usr/lib/*.so
}

doc() {
	cd "$builddir"
	make docs
	mkdir -p "$subpkgdir"/usr/share/doc/objfw
	cp -r docs "$subpkgdir"/usr/share/doc/objfw/html
}

_libobjfw() {
	pkgdesc="Library needed by programs using ObjFW"

	amove usr/lib/libobjfw.so.*
}

_libobjfwrt() {
	pkgdesc="ObjFW Objective-C runtime library"

	amove usr/lib/libobjfwrt.so.*
}

_libobjfwtls() {
	pkgdesc="Library for TLS support for ObjFW"

	amove usr/lib/libobjfwtls.so.*
}

_ofarc() {
	pkgdesc="Utility for handling ZIP, Tar and LHA archives"

	amove usr/bin/ofarc
	amove usr/share/ofarc
}

_ofdns() {
	pkgdesc="Utility for performing DNS requests on the command line"

	amove usr/bin/ofdns
	amove usr/share/ofdns
}

_ofhash() {
	pkgdesc="Utility to hash files with various cryptographic hashes"

	amove usr/bin/ofhash
	amove usr/share/ofhash
}

_ofhttp() {
	pkgdesc="Command line downloader for HTTP(S)"

	amove usr/bin/ofhttp
	amove usr/share/ofhttp
}

sha512sums="
421165ba777d0c0341abd868770b6488104605e99a5ee7c13a9062d1ec9102732eabc09522a4746ff7bbd2cb135b8efbe30ac822fdc7fcc4a1e0bbd56267c6d7  objfw-1.0.5.tar.gz
"
